package com.woniuxy.controller;

import com.woniuxy.entity.User;
import org.springframework.web.bind.annotation.*;

/**
 * @Author：向天浩
 * @Date：2022/1/25 16:48
 * @Description :TODO
 */

//使用restful的风格规范我们的代码和格式
@RestController
public class RestfulController {

    @GetMapping("/get/{id}")
    public String get(@PathVariable int id){

        return id+"";
    };

    @PostMapping("/post")
    public String post(User user){

        return user.toString();
    };

    @PutMapping("/put/{name}/{age}")
    public String update(@PathVariable("name")String name,@PathVariable("age")int age){
      User user=new User();
      user.setName(name);
      user.setAge(age);

      return user.toString();
    };

@DeleteMapping("/delete/{age}")
public String delete(@PathVariable("age")Integer age){

    return age+"";
}

}
